home *** CD-ROM | disk | FTP | other *** search
/ PC Media 20 / PC MEDIA CD20.iso / share / prog / aaformat / aaformat.txt
Encoding:
Text File  |  1992-02-26  |  15.8 KB  |  362 lines

  1. Autodesk Animator files
  2.  
  3.      Following is a detailed description of the FLI file format,
  4. as well as the formats for Autodesk Animator's other main file
  5. types.
  6.  
  7. 1 Flic Files (.FLI)
  8.  
  9.      The details of a FLI file are moderately complex, but the
  10. idea behind it is simple: don't bother storing the parts of a
  11. frame that are the same as the last frame.  Not only does this
  12. save space, but it's very quick.  It's faster to leave a pixel
  13. alone than to set it.
  14.  
  15.      A FLI file has a 128-byte header followed by a sequence of
  16. frames. The first frame is compressed using a bytewise run-length
  17. compression scheme.  Subsequent frames are stored as the
  18. difference from the previous frame.  (Occasionally the first
  19. frame and/or subsequent frames are uncompressed.)  There is one
  20. extra frame at the end of a FLI which contains the difference
  21. between the last frame and the first frame.
  22.  
  23.      The FLI header:
  24.  
  25.      byte size name      meaning
  26.      offset
  27.  
  28.      0    4    size      Length of file, for programs that want
  29.                          to read the FLI all at once if possible.
  30.      4    2    magic     Set to hex AF11.  Please use another
  31.                          value here if you change format (even to
  32.                          a different resolution) so Autodesk
  33.                          Animator won't crash trying to read it.
  34.      6    2    frames    Number of frames in FLI.  FLI files have
  35.                          a maxium length of 4000 frames.
  36.      8    2    width     Screen width (320).
  37.      10   2    height    Screen height (200).
  38.      12   2    depth     Depth of a pixel (8). 142flagsMust be 0.
  39.      16   2    speed     Number of video ticks between frames.
  40.      18   4    next      Set to 0.
  41.      22   4    frit      Set to 0.
  42.      26   102  expand    All zeroes -- for future enhancement.
  43.  
  44.      Next are the frames, each of which has a header:
  45.  
  46.      byte size name      meaning
  47.      offset
  48.      0    4    size      Bytes in this frame.  Autodesk Animator
  49.                          demands that this be less than 64K.
  50.      4    2    magic     Always hexadecimal F1FA
  51.      6    2    chunks    Number of 'chunks' in frame.
  52.      8    8    expand    Space for future enhancements.  All
  53.                          zeros.
  54.  
  55.      After the frame header come the chunks that make up the
  56. frame.  First comes a color chunk if the color map has changed
  57. from the last frame.  Then comes a pixel chunk if the pixels have
  58. changed.  If the frame is absolutely identical to the last frame
  59. there will be no chunks at all.
  60.  
  61.      A chunk itself has a header, followed by the data.  The
  62. chunk header is:
  63.  
  64.      byte size name meaning
  65.      offset
  66.      0    4    size Bytes in this chunk.
  67.      4    2    type Type of chunk (see below).
  68.  
  69.      There are currently five types of chunks you'll see in a FLI
  70. file.
  71.  
  72.      number    name      meaning
  73.      11        FLI_COLOR Compressed color map
  74.      12        FLI_LC    Line compressed -- the most common type
  75.                          of compression for any but the first
  76.                          frame.  Describes the pixel difference
  77.                          from the previous frame.
  78.      13        FLI_BLACK Set whole screen to color 0 (only occurs
  79.                          on the first frame).
  80.      15        FLI_BRUN  Bytewise run-length compression -- first
  81.                          frame only
  82.      16        FLI_COPY  Indicates uncompressed 64000 bytes soon
  83.                          to follow.  For those times when
  84.                          compression just doesn't work!
  85.  
  86.      The compression schemes are all byte-oriented.  If the
  87. compressed data ends up being an odd length a single pad byte is
  88. inserted so that the FLI_COPY's always start at an even address
  89. for faster DMA.
  90. FLI_COLOR Chunks
  91.      The first word is the number of packets in this chunk. This
  92. is followed directly by the packets.  The first byte of a packet
  93. says how many colors to skip.  The next byte says how many colors
  94. to change.  If this byte is zero it is interpreted to mean 256. 
  95. Next follows 3 bytes for each color to change (one each for red,
  96. green and blue).
  97.  
  98. FLI_LC Chunks
  99.      This is the most common, and alas, most complex chunk.   The
  100. first word (16 bits) is the number of lines starting from the top
  101. of the screen that are the same as the previous frame. (For
  102. example, if there is motion only on the bottom line of screen
  103. you'd have a 199 here.)  The next word is the number of lines
  104. that do change.  Next there is the data for the changing lines
  105. themselves.  Each line is compressed individually; among other
  106. things this makes it much easier to play back the FLI at a
  107. reduced size.
  108.  
  109.      The first byte of a compressed line is the number of packets
  110. in this line.  If the line is unchanged from the last frame this 
  111. is zero.  The format of an individual packet is:
  112.  
  113. skip_count
  114. size_count
  115. data
  116.  
  117.      The skip count is a single byte.  If more than 255 pixels
  118. are to be skipped it must be broken into 2 packets. The size
  119. count is also a byte.  If it is positive, that many bytes of data
  120. follow and are to be copied to the screen.  If it's negative a
  121. single byte follows, and is repeated -skip_count times.
  122.  
  123.      In the worst case a FLI_LC frame can be about 70K.  If it
  124. comes out to be 60000 bytes or more Autodesk Animator decides
  125. compression isn't worthwhile and saves the frame as FLI_COPY.
  126.  
  127. FLI_BLACK Chunks
  128.      These are very simple.  There is no data associated with
  129. them at all. In fact they are only generated for the first frame
  130. in Autodesk Animator after the user selects NEW under the FLIC
  131. menu.
  132.  
  133. FLI_BRUN Chunks
  134.      These are much like FLI_LC chunks without the skips.  They
  135. start immediately with the data for the first line, and go line-
  136. by-line from there.  The first byte contains the number of
  137. packets in that line.  The format for a packet is:
  138.  
  139. size_count
  140. data
  141.      If size_count is positive the data consists of a single byte
  142. which is repeated size_count times. If size_count is negative
  143. there are -size_count bytes of data which are copied to the
  144. screen. In Autodesk Animator if the "compressed" data shows signs
  145. of exceeding 60000 bytes the frame is stored as FLI_COPY instead.
  146.  
  147. FLI_COPY Chunks
  148.      These are 64000 bytes of data for direct reading onto the
  149. screen.
  150.  
  151. 2 Picture Files (.GIF)
  152.  
  153.      GIF (Graphics Interchange Format) is a format developed by
  154. CompuServe Information Services.  GIF files are as close to
  155. computer- and resolution-independent as we're likely to see in
  156. the next few years -- there are GIF viewers available for the
  157. Amiga, the Atari ST and 8-bit line, the Tandy Color Computer, the
  158. Apple II, the MacIntosh, Sun workstations, PC compatibles and
  159. most other computers with any sort of graphics display at all. 
  160. There are also programs to convert from the more "native" file
  161. formats (such as DEGAS on the ST, IFF on the Amiga, and MacPaint
  162. on the Mac) to GIF.  Many of these conversion programs are
  163. available free on Compuserve.
  164.  
  165.      GIF files are also fairly densely compressed, using a
  166. modified Lempel-Zif-Welch "ladder" compression scheme similar to
  167. that used in the popular archive programs ARC and PKZIP.  
  168.  
  169.      Unfortunately the nitty-gritty details of what goes into a
  170. GIF file are rather complex, and CompuServe holds the copyright
  171. to much of the documentation.  The PICS forum on CompuServe (type
  172. "go pics" at any exclamation mark prompt) will provide GIF
  173. documentation and much more in the way of useful information to
  174. graphics programmers if you fill out a simple developer's
  175. registration form.  Another place to look for GIF information is
  176. the Autodesk forum on CompuServe; type "go autodesk" to learn
  177. more.
  178.  
  179. 3 Cel Files (.CEL and .PIC)
  180.  
  181.      A cel file has a 32-byte header followed by the uncompressed
  182. color map (768 bytes) followed by the uncompressed pixel image.  
  183.  
  184.      The header is:
  185.      Byte Offset    Contents
  186.            0        Magic Number - 9119 Hexadecimal
  187.            2        Width of cel
  188.            4        Height of cel
  189.            6        Horizontal screen position of upper left
  190.                     corner
  191.            8        Vertical screen position  10Number of bits in a pixel (8)
  192.            11       Compression type (0 for uncompressed)
  193.            12       Size in bytes of cel image (a 4-byte long
  194.                     word)
  195.            16       16 bytes of zero reserved for future use.
  196.  
  197.      A .PIC file uses the same format, with width and height
  198. 320x200 and screen position 0x0.  (.PIC files are generated in
  199. Autodesk Animator if you supply a .PIC file suffix while loading
  200. or saving a single frame.  Otherwise a GIF file is made.)
  201.  
  202. 4 Palette Files (.COL)
  203.  
  204.      A color file is just a binary image of the color palette. 
  205. It consists of 768 bytes -- three bytes for each color.  Each
  206. byte has a value from 0 to 63.  The red byte comes first, then
  207. the green, then the blue.
  208.  
  209. 5 Mask Files (.MSK)
  210.  
  211.      A mask file is is an 8000-byte file.  It contains one bit
  212. for each pixel of the screen.  It goes from left to right, top to
  213. bottom.
  214.  
  215. 6 Text Files (.TXT)
  216.  
  217.    These are just ordinary ASCII files.
  218.  
  219. 7 Font Files (.FNT)
  220.  
  221.      My font files are a slightly strange hybrid.  They started
  222. out as the same type of file that GEM on the ST uses.  Then some
  223. additions were made to make it easier to convert MacIntosh fonts
  224. to a format Autodesk Animator could use.  My apologies for
  225. creating yet another font file format for the PC (this only makes
  226. about 12 I know of...), especially as I don't completely
  227. understand this one myself!
  228.  
  229.      A font file starts out with an 88-byte header.  This is
  230. followed by up to three tables of various sizes:  
  231.      Byte Offset    Name      Meaning
  232.           0         id        Identifier.  Hex 9000 if
  233.                               Mac-converted
  234.           2         size      Point size of font.  Not used by
  235.                               Animator
  236.           4         facename  32 byte name of font.  Not used by
  237.                               Animator
  238.           36        ADE_lo    Lowest ASCII character in font.  
  239.                               More often than not this is 20 hex
  240.                               (space character).
  241.           38        ADE_hi    Highest character in font.
  242.           40        top_dist  unknown, unused by Animator 42asc_distunknown, unused by Animator
  243.           44        hlf_dist  unknown, unused by Animator
  244.           46        des_dist  unknown, unused by Animator
  245.           48        bot_dist  unknown, unused by Animator
  246.           50        wchr_wdt  widest character width
  247.           52        wcel_width     widest 'cell' width (includes
  248.                                    distance to next character)
  249.           54        lft_ofst  unknown, unused by Animator
  250.           56        rgt_ofst  if Mac font, is negative of Mac
  251.                               maxKern value.  Else unknown &
  252.                               unused.
  253.           58        thckning  How bold is bold? Unused by
  254.                               Animator
  255.           60        undrline  How far down to underline? Unused
  256.                               by Animator
  257.           62        lghtng_m  Lightening mask. Mask for light
  258.                               style.  Unused by Animator
  259.           64        skewng_m  Skewing mask for italics.  Rotate
  260.                               line on a 1 bit.  Unused by
  261.                               Animator
  262.           66        flags     Will swap bytes of image if bit 2
  263.                               is non-zero.  (Part of DRI's
  264.                               attempt to make 8086/68000 work
  265.                               together.)
  266.           68        hz_ofst   Unknown, unused in Animator
  267.           72        ch_ofst   Unknown, unused in Animator
  268.           76        fnt_dta   Unknown, unused in Animator
  269.           80        frm_wdt   Byte width of bitmap
  270.           82        frm_hgt   Pixel height of bitmap
  271.           84        nxt_fnt   Unknown, unused in Animator
  272.  
  273.      The first table is a series of 16-bit words containing the
  274. horizontal offset into the font bitmap image of the start of each
  275. letter.  The width of the letter is calculated by subtracting the
  276. offset of the next character from the offset of current
  277. character.  There's one offset for each character in the font,
  278. plus an extra one to give the width of the last character.  This
  279. table is always present.
  280.  
  281.      The second table contains the font image.  This is a single
  282. bit-map for the whole font (as opposed to a series of bitmaps one
  283. for each character).  This table is always present.
  284.  
  285.      The third table is only present in fonts we've translated
  286. from the MacIntosh (that is, if the id field in the header is
  287. hexadecimal 9000).  There are two bytes for each character in the
  288. font.  If both bytes are FF hexidecimal it is a 'missing
  289. character', and will not be drawn.  The first byte is added to
  290. the rgt_ofst field of the header to tell how many pixels to move
  291. to the right (or left if the result is negative) before drawing
  292. this character.  The second byte is how many pixels to move to
  293. the right after drawing this character.
  294. 8 Polygon and Path files (.PLY)
  295.  
  296.      A polygon file has an 8-byte header followed by 6 bytes for
  297. each point of the polygon (2 bytes each x,y,z with z always zero
  298. currently).
  299.  
  300.    Here is the header:
  301.      Byte Offset    Contents
  302.      0              16-bit point count
  303.      2              4 bytes of zero
  304.      6              1 if polygon closed, 0 otherwise
  305.      7              Magic number - hex 99
  306.  
  307. 9 Optics Files (.OPT)
  308.  
  309.      An optics file has a 4-byte header followed by a series of
  310. optical moves records of 50 bytes each.  Each time you click on
  311. CONTINUE MOVE in the OPTICS menu in Autodesk Animator another
  312. record is generated.  The header format is:
  313.      Byte Offset    Contents
  314.      0              Magic Number - 1A3F Hexadecimal
  315.      2              Number of moves in this file.  16-bit count
  316.  
  317.    Here's the format for an individual record:
  318.      Byte Offset    Contents
  319.      0              4 bytes of zero (room for pointer to next
  320.                     record when it's loaded into memory)
  321.      4              Spin center.  x/y/z location (16 bits each)
  322.      10             Spin axis.  x/y/z location (16 bits each)
  323.      16             Spin turns  x/y/z (16 bits each)
  324.      22             Intermediate turns.  Two 16-bit words.  These
  325.                     are values for a conjugation matrix that
  326.                     corresponds to spin axis.
  327.      26             Size center x/y/z location (16 bits each)
  328.      32             x multiplier -- together with x divisor
  329.                     determines how to stretch along x
  330.                     (horizontal) dimension
  331.      34             x divisor
  332.      36             y multiplier
  333.      38             y divisor
  334.      40             both multiplier - applied to both x and y
  335.                     dimensions
  336.      42             both divisor
  337.      44             linear move x/y/z offset (16 bits each)
  338.  
  339. 10 Record Files (.REC)
  340.  
  341.      A record file has a 16-byte header followed by any number of
  342. 8-byte input records.  The header format is:
  343.      Byte Offset    Contents
  344.      0              Magic Number - 0713 Hexadecimal 2long word (4 byte) count of number of input
  345.                     records
  346.      6              4 bytes of 0 
  347.      10             1 if real-time macro, 0 otherwise
  348.      11             5 bytes of 0
  349.  
  350.    The format of a input record is:
  351.      Byte Offset    Contents
  352.      0              Time (in 70th of second) from last record if
  353.                     real-time, 0 otherwise.
  354.      1              Mouse button state.  Bit 0 is left button,
  355.                     bit 1 is right button.  (i.e. the value is 3
  356.                     if both buttons down, 1 if only left button,
  357.                     0 if no buttons down.)
  358.      2              16-bit keyboard code if key pressed, 0
  359.                     otherwise.
  360.      4              16-bit mouse horizontal position
  361.      6              16-bit mouse vertical position
  362.